<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>addmenu</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 16/12/2004</div>
    <p>
      <b>addmenu</b> -  interactive button or menu definition</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>addmenu(button [,submenus] [,action])   </tt>
      </dd>
      <dd>
        <tt>addmenu(gwin,button [,submenus] [,action])   </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>button</b>
        </tt>: a character string. The button name. On Windows operating
  systems (not X_window), an &amp; can be placed before the character
  in the name to be used for keyboard shortcut; this character will be
  underlined on the GUI.</li>
      <li>
        <tt>
          <b>submenus</b>
        </tt>: a vector of character string. The sub_menus items names</li>
      <li>
        <tt>
          <b>action</b>
        </tt>: a list with 2 elements action=list(flag,proc_name)<ul>
          <li>
            <tt>
              <b>flag</b>
            </tt>: an integer (default value is 0)</li>
          <li>
            <tt>
              <b>flag==0</b>
            </tt>the action is defined by a scilab instruction</li>
          <li>
            <tt>
              <b>flag==1</b>
            </tt>the action is defined by a C or Fortran procedure</li>
          <li>
            <tt>
              <b>flag==2</b>
            </tt>: the action is defined by a scilab function</li>
          <li>
            <tt>
              <b>proc_name</b>
            </tt>: a character string which gives the name of scilab variable
    containing the instruction or the name of procedure to
    call.</li>
        </ul>
      </li>
      <li>
        <tt>
          <b>gwin</b>
        </tt>: integer. The number of graphic window where the button is required to be installed</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    The function allows the user to add new buttons or menus in the main
    window or graphics windows command panels.
  </p>
    <dl>
      <dd>
        <b>If</b>
        <tt>
          <b>action</b>
        </tt> argument is not given the action associated
    with a button must be defined by a scilab instruction given by the
    character string variable which name is<p> +  <tt>
            <b>button</b>
          </tt> for a main window command</p>
        <p> +  <tt>
            <b>button_gwin</b>
          </tt> for a graphic window command</p>
      </dd>
      <dd>
        <b>If</b>
        <tt>
          <b>action</b>
        </tt>  argument is set to 0 <tt>
          <b>proc_name</b>
        </tt>
    should be the name of a Scilab string vector.  Actions associated
    with the kth sub_menu must be defined by scilab instructions
    stored in the kth element of the character string variable.</dd>
      <dd>
        <b>If</b>
        <tt>
          <b>action</b>
        </tt> argument is set to 1 <tt>
          <b>proc_name</b>
        </tt>
    designes a C or Fortran procedure, this procedure may be
    interfaced in Fortran subroutine default/fbutn.f or dynamically
    linked with scilab using the <tt>
          <b>link</b>
        </tt> function. The C
    calling sequence is: <tt>
          <b>(char* button_name, int* gwin,int *k)</b>
        </tt>
      </dd>
      <dd>
        <b>If</b>
        <tt>
          <b>action</b>
        </tt> argument is set to 2 <tt>
          <b>proc_name</b>
        </tt>
    designes a Scilab function. This function calling sequence should
    be:<p> +  <tt>
            <b>proc_name(k)</b>
          </tt>for a main window command</p>
        <p> +  <tt>
            <b>proc_name(k,gwin)</b>
          </tt>for a graphic window
    command or a main window command</p>
      </dd>
    </dl>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

addmenu('foo')
foo='disp(''hello'')'

addmenu('Hello',['Franck';'Peter'])
Hello=['disp(''hello Franck'')';'disp(''hello Peter'')']

addmenu(0,'Hello',['Franck';'Peter'])
Hello_0=['disp(''hello Franck'')';'disp(''hello Peter'')']

addmenu('Bye',list(0,'French_Bye'))
French_Bye='disp(''Au revoir'')'

//C defined Callback
// creating Callback code
code=[ '#include ""machine.h""'
 'void foo(char *name,int *win,int *entry)'
 '{'
 '  if (*win==-1) '
 '    sciprint(""menu %s(%i) in Scilab window selected\r\n"",name,*entry+1);'
 '  else'
 '    sciprint(""menu %s(%i) in window %i selected\r\n"",name,*entry+1,*win);'
 '}'];
//creating foo.c file
dir=getcwd(); chdir(TMPDIR)
mputl(code,TMPDIR+'/foo.c');
//reating Makefile
ilib_for_link('foo','foo.o',[],'c');
exec('loader.sce');
chdir(dir);
//add menu
addmenu('foo',['a','b','c'],list(1,'foo'))
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="setmenu.htm">
        <tt>
          <b>setmenu</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="unsetmenu.htm">
        <tt>
          <b>unsetmenu</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="delmenu.htm">
        <tt>
          <b>delmenu</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
